function[correct_count] = kNNValidation(trainingSet, testSet, display) %modus)
% Validates the kNN-algorithm with the wine-dataset.

    if (display >0)
        disp('KNN-CLASSIFICATION');
    end
    %strokes = loadStrokes(modus);
    F = dir('FeatureCombinationDefs/*.txt');
    correct_count = zeros(5,size(F, 1));
    for featureFilter = 1 : size(F, 1)
        featureFilteredTrainingSet = filterFeatures(trainingSet, ['FeatureCombinationDefs/' F(featureFilter).name]);
        featureFilteredTestSet = filterFeatures(testSet, ['FeatureCombinationDefs/' F(featureFilter).name]);
        
        %featureFilteredStrokes = filterFeatures(strokes, ['FeatureCombinationDefs/' F(featureFilter).name]);
        if (display >0)
            disp(['Feature combination according to file [' F(featureFilter).name ']']);
        end
        %D = dir('TrainingSetDefs/*.txt');
       % for split = 1 : size(D, 1)
            %[trainingSet, testSet] = splitIntoTrainingAndTest(featureFilteredStrokes, ['TrainingSetDefs/' D(split).name]);
            %disp(['  Separation into training and test dataset according to file [' D(split).name ']']);
            c = 0;
            for k = [1 2 3 5 10]
                c=c+1;
                correct = 0;
                for i = 1 : size(featureFilteredTestSet, 2)
                    result = kNNClassification(featureFilteredTestSet(2:end, i), k, featureFilteredTrainingSet);
                    if result == featureFilteredTestSet(1, i)
                        correct = correct + 1;
                    end
                end
                if (display >0)
                    disp(['    k = ' num2str(k) ': ' num2str(correct) '/' num2str(size(featureFilteredTestSet, 2)) ' -> ' num2str(correct/size(featureFilteredTestSet, 2)*100) '%']);
                end
                correct_count(c,featureFilter) = correct;
            end
        %end
    end
end
